<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>短信平台设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" type="text/css" href="css/main.css" />
  <link rel="stylesheet" type="text/css" href="../mobile/js/layer/css/layui.css" />
  <link rel="stylesheet" type="text/css" href="css/style.css"/>
  <script src="./js/jquery-1.9.1.js"></script>
  <script src="../mobile/js/layer/layui.js"></script>
  <script src="./js/common.js"></script>
</head>
<body>
<div class="setting_meun">
	<ul class="setting_meunul">
		<a href="setting_information.html"><li>基本设置</li><a/>
		<a href="setting_message.html"><li class="active">短信设置</li></a>
    <a href="setting_template.html"><li>模板设置</li></a>
	</ul>
	<div class="clear"></div>
</div>
<div style="margin: -30px 20px 20px 20px;">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>短信平台设置</legend>
</fieldset>
<blockquote class="layui-elem-quote">
	 <button class="layui-btn btns">短信平台设置</button>
</blockquote>
<form class="layui-form" method="post">
  <div class="layui-form-item">
    <label class="layui-form-label">短信平台</label>
    <div class="layui-input-inline">
     <!--  <select name="platform" id="smsform" autocomplete="off">
        <option>阿里云</option>
      </select> -->
     <input class="layui-input" style="border: none" type="text" value="阿里云" style="width: 320px;" readonly >
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label" style="margin-top: -12px;">短信平台(appKey)</label>
    <div class="layui-input-inline">
      <input type="text" name="appKey" autocomplete="off" placeholder="请输入短信平台配置appkey/keyid" class="layui-input" id="appKey" style="width: 320px;">
    </div>
    <div class="layui-form-mid layui-word-aux" style="margin-left: 130px;">短信平台配置appkey/keyid</div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label" style="margin-top: -12px;">短信平台(secretKey)</label>
    <div class="layui-input-inline">
      <input type="text" name="secretKey" autocomplete="off" placeholder="请输短信平台配置secretKey" class="layui-input" id="secretKey" style="width: 320px;">
    </div>
    <div class="layui-form-mid layui-word-aux" style="margin-left: 130px;">短信平台配置secretKey</div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label" style="margin-top: -12px;">公司名/品牌名/产品名</label>
    <div class="layui-input-inline">
      <input type="text" name="names" autocomplete="off" placeholder="请输公司名/品牌名/产品名" class="layui-input" id="names" style="width: 320px;">
    </div>
    <div class="layui-form-mid layui-word-aux" style="margin-left: 130px;">公司名/品牌名/产品名</div>
  </div>
 <!--  <div class="layui-form-item">
    <label class="layui-form-label" style="margin-top: -12px;">短信模板</label>
    <div class="layui-input-inline">
      <input type="text" name="platform" autocomplete="off" placeholder="请输短信模板" class="layui-input" id="platform" style="width: 320px;">
    </div>
    <div class="layui-form-mid layui-word-aux" style="margin-left: 130px;">短信模板</div>
  </div> -->
  <div class="layui-form-item">
    <label class="layui-form-label">用户实名制</label>
    <div class="layui-input-inline">
      <input type="checkbox" name="usertrue" lay-skin="switch" id="usertrue" lay-text="开启|关闭">
    </div>
    <div class="layui-form-mid layui-word-aux" style="margin-left:-140px;margin-top: 2px;">请选择是否开启该功能</div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn btns" lay-submit="" lay-filter="smsinfo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
</div>
<script>
/*var urls = url+"/admin/config/smsname";
//短信平台名称显示
$.ajax({
  type:'get',
  dataType: 'json',
  url:urls,
  success:function(msg){
     $.each(msg.data, function(i, item) {
      $("#smsform").append("<option value='" + item.smsform + "'>" + item.smsform + "</option>");
      $(".layui-anim-upbit").append("<dd lay-value='" + item.smsform + "'>" + item.smsform + "</dd>");
     });
     $('.layui-anim').find('dd').click(function(){
      var thisVal = $(this).html();
      $('.layui-unselect').val(thisVal);
      $(this).addClass('layui-this').siblings().removeClass('layui-this');
     })
     $('.layui-anim').find('dd').hover(function(){
      $(this).addClass('layui-this').siblings().removeClass('layui-this');
     })
  },
  error:function(){
     layer.alert(msg.infomsg, {icon: 5});     
  }
})*/
//短信设置信息显示
var urls = url + "/admin/config/smsinfo";
$.ajax({
  type: 'get',
  dataType: 'json',
  url: urls,
  success: function(msg){
    if(msg.code == 1){
      $("#appKey").val(msg.data.appKey);
      $("#secretKey").val(msg.data.secretKey);
      $("#names").val(msg.data.names);
        if(msg['data']['usertrue'] == 1){
            $("#usertrue").attr('checked','checked');
            $(".layui-unselect").addClass('layui-form-onswitch');
            $(".layui-unselect em").text('开启');
         }
    }
  },
  error:function(){
    layer.alert("请求失败", {icon: 5});
  }
})
layui.use(['form','layer'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,$ = layui.jquery;
  
  //监听提交
  form.on('submit(smsinfo)', function(data){
    var urls = url + "/admin/config/updatesms";
    $.post(urls,data.field,function(msg){
       var msg = JSON.parse(msg);
       console.log(msg.infomsg);
       if(msg.code == 1){
            layer.alert(msg.infomsg, {icon: 6});
        }else{
            layer.alert(msg.infomsg, {icon: 5});
        }
    }); 
     return false;
  })
});
</script>
</body>
</html>